<?
include("tools.php");
if($_POST){

//open the file and write the data to the text file
	addSubscriber($_POST["sub-email"],$_POST["sub-area"]);

	echo "<p>Thanks for subscribing. You will be Notified by email.<br></p>";

	echo "<p>We will not share you email id to anyone and will be kept confidential</p>";
	mail("searchnirmal100@yahoo.co.in","New Subscriber ".$_POST["sub-email"],$_POST["sub-email"]."-".$_POST["sub-area"]);
}
else if($_GET["unsub"]){

unSubscribe($_GET["unsub"]);
echo "you have unsubscribed successfully";

}
else{
?>
<style>
body{
font-size:11px;
font-family:tahoma;

}
table{

font-size:11px;
font-family:tahoma;

}
</style>	
<form method="post" onsubmit="return validate()">
<table style="width:400px">	
	<tr>
		<td width="200">Your Email Id
		</td>
		<td>
 <input type="text" size="20"  id="sub-email" name="sub-email">
		</td>
	</tr>

	<tr>
		<td>Area your are Interested <br> separated by comma
		</td>
		<td>
<input type="text" size="40" id="sub-area" name="sub-area" placeholder="kilpauk,annanagar">
		</td>
	</tr>


<tr>
		<td colspan="2">
			<input type= "submit" value=" Subscribe " />
		</td>
		
	</tr>


</table>
</form>
<br>
Disclaimer :
<p>
1.This utility is getting the information from online source 
</p>
<p>
2.This utility is developed for educational purpose only.
</p>

<script type="text/javascript">
function validate(){

	var userEmail=document.getElementById("sub-email").value;
	var userArea=document.getElementById("sub-area").value;
	if(userEmail==""){
		alert("Email cannot be empty");
		return false;		
	}

	if(userArea==""){
		alert("Area interested cannot be empty");
		return false;		
	}

	return true;


}

</script>
<?}?>